package com.mapps.jurado;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Point;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class PrincipalActivity extends Activity {

//	private TextView textViewNota;
//	private RelativeLayout layout;

	private static SlidingMenu menu;
	private ActionBar bar;
	
	private final static int CAMERA_REQUEST = 1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_principal_frame);
		
		bar = getActionBar();
		bar.setDisplayHomeAsUpEnabled(true);
		
		Display display = getWindowManager().getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);
		int width = size.x;
		
		menu = new SlidingMenu(this);
		menu.setMode(SlidingMenu.LEFT);
		menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
		menu.setShadowWidthRes(R.dimen.shadow_width);
		menu.setShadowDrawable(R.drawable.shadow);
//		menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		menu.setBehindOffset(width - 100);
		menu.setFadeDegree(0.05f);
		menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
		menu.setMenu(R.layout.fragment_menu);
		
		
//		layout = (RelativeLayout) findViewById(R.id.relativeLayoutPrincipal);
//		textViewNota = (TextView) findViewById(R.id.textViewNota);
		
	}
	
	public static void manipulaMenu(){
		menu.toggle();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu_principal, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menuFoto:
			Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
			startActivityForResult(intentCamera, CAMERA_REQUEST);
			break;
		case android.R.id.home:
			manipulaMenu();
			break;
		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}
	
}
